package com.cskaoyan.last;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端
 *
 * @author 徐文祥
 * @since 2023/05/09 21:07
 */
public class LoginServer {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ServerSocket serverSocket = new ServerSocket(8888);
        Socket socket = serverSocket.accept();
        InputStream in = socket.getInputStream();
        ObjectInputStream objectInput = new ObjectInputStream(in);
        OutputStream out = socket.getOutputStream();
        User user = (User) objectInput.readObject();
        if ("admin".equals(user.getUsernam()) && "admin".equals(user.getPassword())) {
            out.write("登陆成功".getBytes());
        } else {
            out.write("登陆失败".getBytes());
        }
        socket.close();
        serverSocket.close();
    }
}
